import { getContractTotal } from "../../../network/client"
import { debounce } from '../../../utils/Tools'
Page({
  data: {
    search:'',
    contractList:[],
    status:{
      '0':'审核中','1':'已通过','2':'未通过','3':'已完成'
    },
    afterList:[]
  },
  onLoad: function (options) {
    this.handleFilter = debounce(this.handleFilter,300)
    this._getContractTotal(options.customer_id)
  },
  //      函数事件      //
  handleFilter(e){
    const result = this.data.contractList.filter(res =>{
      return res.agreement_order.includes(e.detail)
    })
    if(!result) this.setData({afterList: this.data.contractList})
    this.setData({afterList:result})
  },
  //      网络请求      //
  async _getContractTotal(data){
    const res = await getContractTotal(data)
    if(res.code === 200){
      this.setData({
        contractList: res.data.agreement,
        afterList:res.data.agreement
      })
    }
  }
})